package com.example.controller;
import com.example.entity.supervision.PublicRandom;
import com.example.entity.supervision.PublicRandomResult;
import com.example.service.PublicRandomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by simon on 2018/9/11.
 */
@RestController
@RequestMapping("api/publicRandom")
public class PublicRandomController {

    @Autowired
    PublicRandomService publicRandomService;

    /**
     * 新增 双随机目录
     * @param publicRandom
     * @return
     */
    @RequestMapping(value = "/addPublicRandom", method = RequestMethod.POST)
    Map<String, Object> add(@RequestBody PublicRandom publicRandom) {
        return publicRandomService.add(publicRandom);

    }

    /**
     * 查询 双随机目录
     * @param publicRandom
     * @return
     */
    @RequestMapping(value = "/queryPublicRandom", method = RequestMethod.POST)
    Map<String, Object> query(@RequestBody PublicRandom publicRandom) {
        return publicRandomService.query(publicRandom);
    }

    /**
     * 删除 双随机目录
     * @param publicRandom
     * @return
     */
    @RequestMapping(value = "/deletePublicRandom", method = RequestMethod.POST)
    Map<String, Object> delete(@RequestBody PublicRandom publicRandom) {
        return publicRandomService.delete(publicRandom);

    }

    /**
     * 更新 双随机目录
     * @param publicRandom
     * @return
     */
    @RequestMapping(value = "/updatePublicRandom", method = RequestMethod.POST)
    Map<String, Object> update(@RequestBody PublicRandom publicRandom) {
        return publicRandomService.update(publicRandom);

    }

    /**
     * 新增 双随机 结果
     * @param map
     * @return
     */
    @PostMapping(value = "/addPublicRandomResult")
    Map<String, Object> addRes(@RequestBody Map map) {
        return publicRandomService.addRes(map);
    }

    /**
     * 导出 双随机 结果 (按前端结果)
     * @param publicRandomResultList
     * @return
     */
    @RequestMapping(value = "/exportPublicRandomResult", method = RequestMethod.POST)
    Map<String, Object> exportRes(@RequestBody Map<String, List<PublicRandomResult>> publicRandomResultList) {
        return publicRandomService.exportRes(publicRandomResultList);
    }

    /**
     * 双随机分配完成后导出结果
     * @param map
     * @return
     */
    @RequestMapping(value = "/exportDistribution", method = RequestMethod.POST)
    Map<String, Object> exportDistribution(@RequestBody Map map) {
        return publicRandomService.exportDistribution(map);
    }

    /**
     * 导出 双随机 结果 (事后导出)
     * @param prIdMap
     * @return
     */
    @RequestMapping(value = "/exportPublicRandomResAft", method = RequestMethod.POST)
    Map<String, Object> exportResAft(@RequestBody Map prIdMap) {
        return publicRandomService.exportResAft(prIdMap);
    }

    /**
     * 导出 双随机主体单位
     * @param map
     * @return
     */
    @RequestMapping(value = "/exportRandomPort", method = RequestMethod.POST)
    Map<String, Object> exportRandomPort(@RequestBody Map map) {
        return publicRandomService.exportRandomPort(map);
    }

    /**
     * 双随机获取监管单位
     * @param map
     * @return
     */
    @RequestMapping(value = "/findUnit", method = RequestMethod.POST)
    Map<String, Object> findUnit(@RequestBody Map map) {
        return publicRandomService.findUnit(map);
    }



    /**
     * 双随机获取监管单位下的用户信息
     * @param map
     * @return
     */
    @RequestMapping(value = "/queryUnit", method = RequestMethod.POST)
    Map<String, Object> queryUnit(@RequestBody Map map) {
        return publicRandomService.queryUnit(map);
    }


    /**
     * 双随机点击开始分配
     * @param map
     * @return
     */
    @RequestMapping(value = "/startDistribution", method = RequestMethod.POST)
    Map<String, Object> startDistribution(@RequestBody Map map) {
        return publicRandomService.startDistribution(map);
    }


}
